package com.gaoyang.util;

import com.gaoyang.domain.DianPingUser;
import com.gaoyang.domain.MinshengUser;

import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class HttpUtils4Black {
	public static String postUrl4ZSYH(String requestUrl,
			Map<String, String> paramMap) {
		StringBuffer strbuffer = new StringBuffer();
		String paramUrl = "";
		if ((paramMap != null) && (paramMap.size() > 0)) {
			for (Map.Entry entry : paramMap.entrySet()) {
				String key = String.valueOf(entry.getKey());
				String value = String.valueOf(entry.getValue());
				strbuffer.append(key);
				strbuffer.append("=");
				strbuffer.append(value);
				strbuffer.append("&");

			}
			paramUrl = strbuffer.toString();
			paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
		}

		HttpURLConnection connection = null;
		StringBuffer sb = new StringBuffer("");
		try {
			URL url = new URL(requestUrl);
			connection = (HttpURLConnection) url.openConnection();
			connection.setDoOutput(true);
			connection.setDoInput(true);
			connection.setRequestMethod("POST");
			connection.setUseCaches(false);
			connection.setInstanceFollowRedirects(true);
			connection.setRequestProperty("Accept", "*/*");
			connection.connect();

			DataOutputStream writer = new DataOutputStream(
					connection.getOutputStream());

			writer.writeBytes(paramUrl);
			writer.flush();
			writer.close();

			BufferedReader reader = new BufferedReader(new InputStreamReader(
					connection.getInputStream(), "utf-8"));
			String lines;
			while ((lines = reader.readLine()) != null) {
				lines = new String(lines.getBytes());
				sb.append(lines);
			}

			reader.close();
			connection.disconnect();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (ProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (connection != null) {
				connection.disconnect();
			}
		}
		return sb.toString();
	}

	public static String postUrl4BaoJie(String requestUrl, Map<String, String> paramMap) {
		StringBuffer strbuffer = new StringBuffer();
		String paramUrl = "";
		if ((paramMap != null) && (paramMap.size() > 0)) {
			for (Map.Entry entry : paramMap.entrySet()) {
				String key = String.valueOf(entry.getKey());
				String value = String.valueOf(entry.getValue());
				strbuffer.append(key);
				strbuffer.append("=");
				strbuffer.append(value);
				strbuffer.append("&");
			}
			paramUrl = strbuffer.toString();
			paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
		}

		HttpURLConnection connection = null;
		StringBuffer sb = new StringBuffer("");
		try {
			URL url = new URL(requestUrl);
			connection = (HttpURLConnection) url.openConnection();
			connection.setDoOutput(true);
			connection.setDoInput(true);
			connection.setRequestMethod("POST");
			connection.setUseCaches(false);
			connection.setInstanceFollowRedirects(true);
			connection.setRequestProperty("Host", "zglynk.com");
			connection.setRequestProperty("Origin", "http://zglynk.com");
			connection.setRequestProperty("Upgrade-Insecure-Requests","1");
			connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
			connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045331 Mobile Safari/537.36 MMWEBID/8688 MicroMessenger/7.0.19.1760(0x27001339) Process/tools WeChat/arm64 NetType/4G Language/zh_CN ABI/arm64");
			connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
			connection.setRequestProperty("X-Requested-With", "com.tencent.mm");
			connection.setRequestProperty("Referer", "http://zglynk.com/ITS/itsApp/goSubscribe.action?subscribeId=64");
			connection.setRequestProperty("Cookie", "JSESSIONID=8655DE11BDA75155B34C1A39C534DE00");

			connection.connect();
			DataOutputStream writer = new DataOutputStream(connection.getOutputStream());
			writer.writeBytes(paramUrl);
			writer.flush();
			writer.close();
			BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
			String lines;
			while ((lines = reader.readLine()) != null) {
				lines = new String(lines.getBytes());
				sb.append(lines);
			}
			reader.close();
			connection.disconnect();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (ProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (connection != null) {
				connection.disconnect();
			}
		}
		return sb.toString();
	}
	
	public static String postUrl4Zhongxin(String requestUrl, Map<String, String> paramMap) {
		StringBuffer strbuffer = new StringBuffer();
		String paramUrl = "";
		if ((paramMap != null) && (paramMap.size() > 0)) {
			for (Map.Entry entry : paramMap.entrySet()) {
				String key = String.valueOf(entry.getKey());
				String value = String.valueOf(entry.getValue());
				strbuffer.append(key);
				strbuffer.append("=");
				strbuffer.append(value);
				strbuffer.append("&");
			}
			paramUrl = strbuffer.toString();
			paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
		}

		HttpURLConnection connection = null;
		StringBuffer sb = new StringBuffer("");
		try {
			URL url = new URL(requestUrl);
			connection = (HttpURLConnection) url.openConnection();
			connection.setDoOutput(true);
			connection.setDoInput(true);
			connection.setRequestMethod("POST");
			connection.setRequestProperty("host", "s.creditcard.ecitic.com");
			connection.setRequestProperty("connection", "keep-alive");
			connection.setRequestProperty("pragma", "no-cache");
			connection.setRequestProperty("cache-control", "no-cache");
			connection.setRequestProperty("accept", "application/json, text/plain, */*");
			connection.setRequestProperty("origin", "https://s.creditcard.ecitic.com");
			connection.setRequestProperty("x-requested-with", "XMLHttpRequest");
			connection.setRequestProperty("user-agent", "Mozilla/5.0 (Linux; Android 7.1.1; vivo X9 Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36 DKKJ/4.1.2/[DKKJ_TOWER_1.2]");
			connection.setRequestProperty("content-type", "application/json;charset=UTF-8");
			connection.setRequestProperty("referer", "https://s.creditcard.ecitic.com/rb-mktweb/qg_order_jf.html");
			connection.setRequestProperty("cookie", "__utma=124568792.1819033724.1512355403.1512355403.1512355403.1; __utmb=124568792; __utmc=124568792; __utmz=124568792.1512355403.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); citicbank_cookie=!hS+cfh+165t8U8csQIzMjRcbGG4hAIAqu1y2ojDRtRXzVu2wYH7sHf4q84zFS7fw9Ubn8MeqzZujZjs=; JSESSIONID_BASEH5=dkkj_d966ac63-592e-4e42-bb06-19760b9b5438; citic_ucname=%E9%AB%98%E6%B4%8B; JSESSIONID_DKKJ=dkkj_d966ac63-592e-4e42-bb06-19760b9b5438");
			connection.connect();
			DataOutputStream writer = new DataOutputStream(connection.getOutputStream());
			writer.writeBytes(paramUrl);
			writer.flush();
			writer.close();
			BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
			String lines;
			while ((lines = reader.readLine()) != null) {
				lines = new String(lines.getBytes());
				sb.append(lines);
			}
			reader.close();
			connection.disconnect();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (ProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (connection != null) {
				connection.disconnect();
			}
		}
		return sb.toString();
	}


	public static String sendPost4Zhongxin(String url,String params, String cookie)throws IOException{
		OutputStreamWriter out = null;
		BufferedReader reader = null;
		String response="";
		try {
			URL httpUrl = null; //HTTP URL类 用这个类来创建连接
			//创建URL
			httpUrl = new URL(url);
			//建立连接
			HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection();
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setRequestMethod("POST");
			conn.setRequestProperty("host", "s.creditcard.ecitic.com");
			conn.setRequestProperty("connection", "keep-alive");
			conn.setRequestProperty("pragma", "no-cache");
			conn.setRequestProperty("cache-control", "no-cache");
			conn.setRequestProperty("accept", "application/json, text/plain, */*");
			conn.setRequestProperty("origin", "https://s.creditcard.ecitic.com");
			conn.setRequestProperty("x-requested-with", "XMLHttpRequest");
			conn.setRequestProperty("user-agent", "Mozilla/5.0 (Linux; Android 7.1.1; vivo X9 Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36 DKKJ/4.1.2/[DKKJ_TOWER_1.2]");
			conn.setRequestProperty("content-type", "application/json;charset=UTF-8");
			conn.setRequestProperty("referer", "https://s.creditcard.ecitic.com/rb-mktweb/qg_order_jf.html");
			conn.setRequestProperty("cookie", cookie);
			//
			conn.connect();
			//POST请求
			out = new OutputStreamWriter(
					conn.getOutputStream());
			out.write(params);
			out.flush();
			//读取响应
			reader = new BufferedReader(new InputStreamReader(
					conn.getInputStream()));
			String lines;
			while ((lines = reader.readLine()) != null) {
				lines = new String(lines.getBytes(), "utf-8");
				response+=lines;
			}
			reader.close();
			// 断开连接
			conn.disconnect();
		} catch (Exception e) {
			System.out.println("发送 POST 请求出现异常！"+e);
			e.printStackTrace();
		}
		//使用finally块来关闭输出流、输入流
		finally{
			try{
				if(out!=null){
					out.close();
				}
				if(reader!=null){
					reader.close();
				}
			}
			catch(IOException ex){
				ex.printStackTrace();
			}
		}

		return response;
	}

//	public static String sendGet4Zhongxin(String url) {
//		String result = "";
//		BufferedReader in = null;
//		try {
//			String urlNameString = url;
//			URL realUrl = new URL(urlNameString);
//			URLConnection conn = realUrl.openConnection();
//
//			conn.setDoOutput(true);
//			conn.setDoInput(true);
//			conn.setRequestProperty("host", "s.creditcard.ecitic.com");
//			conn.setRequestProperty("connection", "keep-alive");
//			conn.setRequestProperty("pragma", "no-cache");
//			conn.setRequestProperty("cache-control", "no-cache");
//			conn.setRequestProperty("accept", "image/webp,image/*,*/*;q=0.8");
//			conn.setRequestProperty("origin", "https://s.creditcard.ecitic.com");
//			conn.setRequestProperty("x-requested-with", "XMLHttpRequest");
//			conn.setRequestProperty("user-agent", "Mozilla/5.0 (Linux; Android 7.1.1; vivo X9 Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36 DKKJ/4.1.2/[DKKJ_TOWER_1.2]");
//			conn.setRequestProperty("content-type", "application/json;charset=UTF-8");
//			conn.setRequestProperty("referer", "https://s.creditcard.ecitic.com/rb-mktweb/qg_order_jf.html");
//			conn.setRequestProperty("cookie", "SESSIONID_RB=C9F7A43B078B4188F8D5E715F91078FD; __utma=124568792.273246600.1513777221.1513777221.1513777221.1; __utmb=124568792; __utmc=124568792; __utmz=124568792.1513777221.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); citicbank_cookie=!lK0E2BXl1AbIpYIsQIzMjRcbGG4hAMPdhbYCoXtyNPtQXfgWerIdJP2nn+zXzidElGJMkJDYrj9CaPk=; JSESSIONID_BASEH5=dkkj_cf151ebe-386c-4c6f-a91c-bdceae01d233; citic_ucname=%E9%AB%98%E6%B4%8B; JSESSIONID_DKKJ=dkkj_cf151ebe-386c-4c6f-a91c-bdceae01d233");
//
//			conn.connect();
//			Map map = conn.getHeaderFields();
////			for (Object key : map.keySet()) {
////				System.out.println(key + "--->" + map.get(key));
////			}
//			in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
//			String line;
//			while ((line = in.readLine()) != null) {
//				result = result + line;
//			}
//		} catch (Exception e) {
//			System.out.println("发送GET请求出现异常！" + e);
//			e.printStackTrace();
//			try {
//				if (in != null)
//					in.close();
//			} catch (Exception e2) {
//				e2.printStackTrace();
//			}
//		} finally {
//			try {
//				if (in != null)
//					in.close();
//			} catch (Exception e2) {
//				e2.printStackTrace();
//			}
//		}
//		return result;
//	}

	public static File downloadFile(String urlPath, String downloadDir, String cookie) {
		File file = null;
		try {
			// 统一资源
			URL url = new URL(urlPath);
			// 连接类的父类，抽象类
			URLConnection urlConnection = url.openConnection();
			// http的连接类
			HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
			httpURLConnection.setDoOutput(true);
			httpURLConnection.setDoInput(true);
			httpURLConnection.setRequestProperty("host", "s.creditcard.ecitic.com");
			httpURLConnection.setRequestProperty("connection", "keep-alive");
			httpURLConnection.setRequestProperty("pragma", "no-cache");
			httpURLConnection.setRequestProperty("cache-control", "no-cache");
			httpURLConnection.setRequestProperty("accept", "image/webp,image/*,*/*;q=0.8");
			httpURLConnection.setRequestProperty("origin", "https://s.creditcard.ecitic.com");
			httpURLConnection.setRequestProperty("x-requested-with", "XMLHttpRequest");
			httpURLConnection.setRequestProperty("user-agent", "Mozilla/5.0 (Linux; Android 7.1.1; vivo X9 Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36 DKKJ/4.1.2/[DKKJ_TOWER_1.2]");
			httpURLConnection.setRequestProperty("content-type", "application/json;charset=UTF-8");
			httpURLConnection.setRequestProperty("referer", "https://s.creditcard.ecitic.com/rb-mktweb/qg_order_jf.html");
			httpURLConnection.setRequestProperty("cookie", cookie);

			// 打开到此 URL 引用的资源的通信链接（如果尚未建立这样的连接）。
			httpURLConnection.connect();

			// 文件大小
			int fileLength = httpURLConnection.getContentLength();

			// 文件名
			String filePathUrl = httpURLConnection.getURL().getFile();
			String fileFullName = filePathUrl.substring(filePathUrl.lastIndexOf(File.separatorChar) + 1);

			System.out.println("file length---->" + fileLength);

			URLConnection con = url.openConnection();

			BufferedInputStream bin = new BufferedInputStream(httpURLConnection.getInputStream());

			String path = downloadDir + File.separatorChar + "1.png";
			file = new File(path);
			if (!file.getParentFile().exists()) {
				file.getParentFile().mkdirs();
			}
			OutputStream out = new FileOutputStream(file);
			int size = 0;
			int len = 0;
			byte[] buf = new byte[1024];
			while ((size = bin.read(buf)) != -1) {
				len += size;
				out.write(buf, 0, size);
				// 打印下载百分比
				// System.out.println("下载了-------> " + len * 100 / fileLength +
				// "%\n");
			}
			bin.close();
			out.close();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			return file;
		}

	}

	public static String sendGet(String url) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url;
			URL realUrl = new URL(urlNameString);
			URLConnection connection = realUrl.openConnection();

//			connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
////			connection.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
//			connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
//			connection.setRequestProperty("Connection", "keep-alive");
//			connection.setRequestProperty("Cookie", "checkInCloseState=ignored; likeTips=closed; JSESSIONID=A13E86CC11B9DD81464ACCBE6FA6B9EE; _lxsdk_s=%7C%7C0");
//			connection.setRequestProperty("Host", "s.dianping.com");
//			connection.setRequestProperty("Upgrade-Insecure-Requests", "1");
//			connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36");

			connection.connect();
			Map map = connection.getHeaderFields();
//			for (Object key : map.keySet()) {
//				System.out.println(key + "--->" + map.get(key));
//			}
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			System.out.println("发送GET请求出现异常！" + e);
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}

	public static String sendMinshengGet(String url, Map<String, String> paramMap, String cmbc_uuid) {
		String result = "";
		BufferedReader in = null;
		try {
			String paramUrl = "";
			StringBuffer strbuffer = new StringBuffer();
			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");

				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}

			String urlNameString = url + strbuffer;
			URL realUrl = new URL(urlNameString);
			URLConnection connection = realUrl.openConnection();

			connection.setRequestProperty("connection", "keep-alive");
			connection.setRequestProperty("accept", "application/json, text/plain, */*");
			connection.setRequestProperty("user-agent", "Mozilla/5.0 (Linux; Android 7.1.1; vivo X9 Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043508 Safari/537.36 MicroMessenger/6.5.13.1100 NetType/WIFI Language/zh_CN");
			connection.setRequestProperty("referer", "https://prefacty.creditcard.cmbc.com.cn/home.$15563.html");
			connection.setRequestProperty("accept-language", "zh-CN,en-US;q=0.8");
			connection.setRequestProperty("cookie", "JSESSIONID=8300D6BB2A3457BD289618210CED80C8; cmbc_uuid=" + cmbc_uuid +"; Hm_lvt_a402dc646b9ff3767a84eba34e4a86f8=1503644190; Hm_lpvt_a402dc646b9ff3767a84eba34e4a86f8=1503903164");
			connection.setRequestProperty("content-length", "0");

			connection.connect();
			Map map = connection.getHeaderFields();
//			for (Object key : map.keySet()) {
//				System.out.println(key + "--->" + map.get(key));
//			}
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			System.out.println("发送GET请求出现异常！" + e);
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}

	public static String sendDianpingGet(String url, DianPingUser user) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url;
			URL realUrl = new URL(urlNameString);
			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
			connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
			connection.setRequestProperty("Connection", "keep-alive");
			connection.setRequestProperty("Cookie", "checkInCloseState=ignored; likeTips=closed; _hc.v=1da46a82-cdfd-5619-fe3f-fe57765f353b.1505815845; dper=" + user.getDper() + "; ua=" + user.getTel() + "; ll=7fd06e815b796be3df069dec7836c3df; _lxsdk_cuid=15e99a09a0fc8-0882c78b7cee1c-31637e01-13c680-15e99a09a0fc8; _lxsdk=15e99a09a0fc8-0882c78b7cee1c-31637e01-13c680-15e99a09a0fc8; isChecked=checked; JSESSIONID=82B0FB43D56C041D2653876392FF8858; aburl=1; cy=2; cye=beijing; _lxsdk_s=15e99a09a12-325-20e-610%7C%7C17");
			connection.setRequestProperty("Host", "s.dianping.com");
			connection.setRequestProperty("Upgrade-Insecure-Requests", "1");
			connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36");
			connection.connect();
			Map map = connection.getHeaderFields();
//			for (Object key : map.keySet()) {
//				System.out.println(key + "--->" + map.get(key));
//			}
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			System.out.println("发送GET请求出现异常！" + e);
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}

	public static String sendTaobaokeGet(String url) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url;
			URL realUrl = new URL(urlNameString);
			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty(":authority", "detail.tmall.com");
			connection.setRequestProperty(":method", "GET");
			connection.setRequestProperty(":path", url);
			connection.setRequestProperty(":scheme", "https");
			connection.setRequestProperty("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			connection.setRequestProperty("accept-encoding", "deflate, sdch, br");
			connection.setRequestProperty("accept-language", "zh-CN,zh;q=0.8");
			connection.setRequestProperty("cache-control", "max-age=0");
			connection.setRequestProperty("cookie", "thw=cn; miid=875413649462218552; uc2=wuf=https%3A%2F%2Ftrade.tmall.com%2Fdetail%2ForderDetail.htm%3Fspm%3Da220l.12.0.0.atnF74%26null%3Dnull%26bizOrderId%3D2617231387716326; _uab_collina=148924472113707239909363; v=0; ctoken=vfwVZcYM1kp0tu5waeVLiceland; uc3=sg2=VFPrdW8zoyGQ3KyjElSjWTC3LvsYop%2BrezdEhfx%2BNoQ%3D&nk2=tYqFc05l1rsSJzIwyVU%3D&id2=VAStVnLdLZMV&vt3=F8dARVWNUnzfXFmAaJM%3D&lg2=UtASsssmOIJ0bQ%3D%3D; existShop=MTQ4OTQ3Mzg0NA%3D%3D; uss=UtAEEYwJEpUbq1m4EhL1zenU1EuZRmYa%2BiyeUNqY0rbshiXszyM9bKWUZQ%3D%3D; lgc=%5Cu81F3%5Cu7231%5Cu53D1%5Cu5982%5Cu96EA0204; tracknick=%5Cu81F3%5Cu7231%5Cu53D1%5Cu5982%5Cu96EA0204; cookie2=4a6bc6a76997616f92dad083949325b7; sg=485; mt=np=&ci=0_1; cookie1=VAYq3MRGHGDP5x1T8NO7TJdAd5pYsi720ritNXzDczI%3D; unb=757232148; skt=bad2079c2ef6ca0f; t=cc58407bf4e4e0c33218bf3c4d039458; _cc_=U%2BGCWk%2F7og%3D%3D; tg=0; _l_g_=Ug%3D%3D; _nk_=%5Cu81F3%5Cu7231%5Cu53D1%5Cu5982%5Cu96EA0204; cookie17=VAStVnLdLZMV; linezing_session=pLDIhREdo7wsNtwV1A35ngMt_1489473878511TuGG_1; _tb_token_=ebb5ee54b6301; uc1=cookie14=UoW%2FVObws7d28g%3D%3D&lng=zh_CN&cookie16=VFC%2FuZ9az08KUQ56dCrZDlbNdA%3D%3D&existShop=false&cookie21=UtASsssme%2BBq&tag=2&cookie15=U%2BGCWk%2F75gdr5Q%3D%3D&pas=0; cna=bLxGETrQ7w4CAX0jM6IPFKhw; _umdata=0823A424438F76ABB0E6774F9F8A8DCB971FFE887666C70C5B2EEA7F1FE2DE37EE97D7A5A6C1610FCD43AD3E795C914C4D042EC9DFA2C6DFC8268D19426E80C3; l=AkxMGsYfWqpBSW7Ox47QoO8WnKB-hfAv; isg=AnR0o6E5kGAvVgQp2zGsuRWPRTT_tpg3gNy9CA7VAP-CeRTDNl1oxyq7jwZb");
//			connection.setRequestProperty("refer", "https://s.click.taobao.com/t_js?tu=https%3A%2F%2Fs.click.taobao.com%2Ft%3Fspm%3Da311n.8189758%2Fa.90200000.1.432ZJD%26e%3Dm%253D2%2526s%253DFALaBssK1t5w4vFB6t2Z2ueEDrYVVa64LKpWJ%252Bin0XLjf2vlNIV67qmQRxWEeB19Nq%252BDna%252F8eQepSO1rEcg0b8LN6jK7NHy78hWRy4bCQTYQd0cc4xbQVFKrHkWq9YOLwd3%252F8TPoKJgwqccMEwZVKxKihrUHtpJuYM7FHiwA1nbNkn9R3PC9OI1GG7Jaai63zQG%252BCWQ69P1YdC0Lyzdv9cYOae24fhW0%26pvid%3D11_58.31.14.111_1369_1489422947754%26ref%3Dhttps%253A%252F%252Fuland.taobao.com%252Fcoupon%252Fedetail%253Fe%253DGyIHiUeO40oN%25252BoQUE6FNzBenlb4YusJVQRgq5ELCLwZxZ778529PF%25252FkV8Ovtq%25252BCjRPai36SzjGQYGBU%25252BUYnml0YUejVMpzGc7sRUcQe1PUdw8qc1XLan0YgD8TGIivUFwexwE9iPmnf9jfeG5Bp2avNVXe6BDqYX%2526pid%253Dmm_120456803_22352448_74180429%2526af%253D1%26et%3DcEheJbOZekpD2AX%252Fie57NyH3gjAHuotM");
			connection.setRequestProperty("accept-encoding", "deflate, sdch, br");
			connection.setRequestProperty("upgrade-insecure-requests", "1");
			connection.setRequestProperty("user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
			connection.connect();
			Map map = connection.getHeaderFields();
//			for (Object key : map.keySet()) {
//				System.out.println(key + "--->" + map.get(key));
//			}
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			System.out.println("发送GET请求出现异常！" + e);
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}

	public static String sendGetCookie(String url,String name) {
		String result = "";
		URLConnection connection = null;
		try {
			String urlNameString = url;
			URL realUrl = new URL(urlNameString);
			connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
			connection.setRequestProperty("Cache-Control", "no-cache");
			connection.setRequestProperty("Host","shenghuojia.campaign.socialjia.com");
			connection.setRequestProperty("Pragma", "no-cache");
			connection.setRequestProperty("Proxy-Connection", "keep-alive");
//			connection.setRequestProperty("Referer","http://shenghuojia.campaign.socialjia.com/index.php?a=ScoreExchange&m=index&brandid=1&apiKey=8a674fcd013ccbc5e0fc206d3b1771c4&timestamp=1451443756&sig=8e4b7a7e3877904d8ac7a89550a8c885&openid=ocJOVjkgTgRH_bUjjqD-6Lg6bX6c");
			connection.setRequestProperty("Upgrade-Insecure-Requests", "1");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Linux; U; Android 5.0.1; zh-cn; MX4 Pro Build/LRX22C) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.4 TBS/025488 Mobile Safari/533.1 MicroMessenger/6.3.8.50_r251a77a.680 NetType/WIFI Language/zh_CN");
			connection.connect();
			String set_cookie = connection.getHeaderField("Set-Cookie");
			return getCookie("PHPSESSID", set_cookie);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(connection != null){
				
			}
		}
		return result;
	}
	public static String sendGet(String url, Map<String, String> paramMap, String cookie) {
		String result = "";
		BufferedReader in = null;
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		if ((paramMap != null) && (paramMap.size() > 0)) {
			for (Map.Entry entry : paramMap.entrySet()) {
				String key = String.valueOf(entry.getKey());
				String value = String.valueOf(entry.getValue());
				strbuffer.append(key);
				strbuffer.append("=");
				strbuffer.append(value);
				strbuffer.append("&");

			}
			paramUrl = strbuffer.toString();
			paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
		}

		try {
			String urlNameString = url + strbuffer;
			URL realUrl = new URL(urlNameString);

			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
			connection.setRequestProperty("Cache-Control", "no-cache");
			connection.setRequestProperty("Cookie",cookie);
			connection.setRequestProperty("Host","app.bjzgh12351.org");
			connection.setRequestProperty("Pragma", "no-cache");
			connection.setRequestProperty("Proxy-Connection", "keep-alive");
//			connection.setRequestProperty("Referer","http://shenghuojia.campaign.socialjia.com/index.php?a=ScoreExchange&m=index&brandid=1&apiKey=8a674fcd013ccbc5e0fc206d3b1771c4&timestamp=1451443756&sig=8e4b7a7e3877904d8ac7a89550a8c885&openid=ocJOVjkgTgRH_bUjjqD-6Lg6bX6c");
			connection.setRequestProperty("Upgrade-Insecure-Requests", "1");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Linux; U; Android 5.0.1; zh-cn; MX4 Pro Build/LRX22C) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.4 TBS/025488 Mobile Safari/533.1 MicroMessenger/6.3.8.50_r251a77a.680 NetType/WIFI Language/zh_CN");
			connection.connect();
			String set_cookie = connection.getHeaderField("Set-Cookie");
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}
	public static String getCookie(String name,String cookieStr){
			String cookie = "";
		if(cookieStr != null && !"".equals(cookieStr)){
			cookieStr = cookieStr.replaceAll("^\\s*$", "");
			String[] cookies = cookieStr.split(";");
			for(String c : cookies){
				String key = c.split("=")[0];
				String value = c.split("=")[1];
				if(name.equals(key)){
					return value;
				}
			}
		}
		return cookie;
	}

	public static String setJingYiTongRequest(Map<String, String> paramMap) {
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		String result = "";
		BufferedReader in = null;
//		if ((paramMap != null) && (paramMap.size() > 0)) {
//			for (Map.Entry entry : paramMap.entrySet()) {
//				String key = String.valueOf(entry.getKey());
//				String value = String.valueOf(entry.getValue());
//				strbuffer.append(key);
//				strbuffer.append("=");
//				strbuffer.append(value);
//				strbuffer.append("&");
//			}
//			paramUrl = strbuffer.toString();
//			paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
//		}
		try {
//			String url = "http://m.benmu-health.com/bjmc/api/Date/getNewDate?" + paramUrl;
			String url = "https://wechat.benmu-health.com/mobile/wx/product/list/v2?_=1536216662859&hosCode=H107861&firstDeptCode=2360100&secondDeptCode=2360100_2360100&xa7w6pf=9a811d755ee3b73f4bcd83ced0ef3e72&_=1536216662862";
			System.out.println(url);
			String urlNameString = url;
			URL realUrl = new URL(urlNameString);

			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Host","wechat.benmu-health.com");
			connection.setRequestProperty("connection","keep-alive");
			connection.setRequestProperty("content-length","264");
			connection.setRequestProperty("Accept","application/json, text/plain, */*");
			connection.setRequestProperty("ucp","c3qyCqVTdwyzmaDmpuQYSzjQ48LShdzskXCp-4yn3MeLkayMwPf8ORTOnbTWIaDnChFtcw..");
			connection.setRequestProperty("lgd","");
			connection.setRequestProperty("attention","1");
			connection.setRequestProperty("origin","m.benmu-health.com");
			connection.setRequestProperty("x-requested-with","XMLHttpRequest");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Linux; Android 8.0; MIX 2 Build/OPR1.170623.027; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043909 Mobile Safari/537.36 MicroMessenger/6.6.5.1280(0x26060533) NetType/WIFI Language/zh_CN");
			connection.setRequestProperty("content-type","application/x-www-form-urlencoded; charset=UTF-8");
			connection.setRequestProperty("referer", "https://wechat.benmu-health.com/wechatV2/");
			connection.setRequestProperty("accept-language","zh-CN,en-US;q=0.8");
			connection.setRequestProperty("Cookie", "bm_session=hhNTHy93kW1Q7SFyANWH6tUpCJKCmzBk_5120722; __jsluid=ac2a7e377955185bf8aeb68b23299f90; _ucp=c3qyCqVTdwyzmaDmpuQYSzjQ48LShdzskXCp-4yn3MeLkayMwPf8ORTOnbTWIaDnChFtcw..; _attention=1; bm_session=hhNTHy93kW1Q7SFyANWH6tUpCJKCmzBk_5120722; bm_session_tm=1536216659676");

			connection.connect();
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}

		return result;
	}

	public static String setDianPingLoginRequest(String address, Map<String, String> paramMap) {
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		String result = "";
		BufferedReader in = null;
		try {

			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");
				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}
			String url = address + "?" + paramUrl;
			URL realUrl = new URL(url);

			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","*/*");
			connection.setRequestProperty("Accept-Encoding","gzip, deflate, br");
			connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
			connection.setRequestProperty("Connection","keep-alive");
			connection.setRequestProperty("Cookie", "PHOENIX_ID=0a01783d-1592a984866-5694e8; _hc.v=\"970e51a7-8d29-4c94-b8d1-fb74b0a689aa.1482481011\"");
			connection.setRequestProperty("Host","www.dianping.com");
			connection.setRequestProperty("Referer","https://mlogin.dianping.com/login/password?redir=https%3A%2F%2Fm.dianping.com%2Fmy");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36");

			connection.connect();
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}

		return result;
	}

	public static List<String> returnCookies(String address, Map<String, String> paramMap) {
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		List<String> result = new ArrayList();
		BufferedReader in = null;
		try {

			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");
				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}
			String url = address + "?" + paramUrl;
			URL realUrl = new URL(url);

			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","*/*");
			connection.setRequestProperty("Accept-Encoding","gzip, deflate, br");
			connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
			connection.setRequestProperty("Connection","keep-alive");
			connection.setRequestProperty("Cookie", "PHOENIX_ID=0a01783d-1592a984866-5694e8; _hc.v=\"970e51a7-8d29-4c94-b8d1-fb74b0a689aa.1482481011\"");
			connection.setRequestProperty("Host","www.dianping.com");
			connection.setRequestProperty("Referer","https://mlogin.dianping.com/login/password?redir=https%3A%2F%2Fm.dianping.com%2Fmy");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36");

			connection.connect();
			Map<String, List<String>> cookies = connection.getHeaderFields();
			result = cookies.get("Set-Cookie");

		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}


	public static String setDianPingRequest(String url, Map<String, String> paramMap, DianPingUser user) {
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		String result = "";
		BufferedReader in = null;
		try {

			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");
				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}
			url += paramUrl;
			URL realUrl = new URL(url);

			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","application/json");
			connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
			connection.setRequestProperty("Connection","keep-alive");
			connection.setRequestProperty("Content-Length","225");
			connection.setRequestProperty("Content-Type","application/json; charset=utf-8");
			connection.setRequestProperty("Host","s.dianping.com");
			connection.setRequestProperty("Origin","http://s.dianping.com");
			connection.setRequestProperty("Referer","http://s.dianping.com/event/" + paramMap.get("offlineActivityId"));
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36");
			connection.setRequestProperty("Cookie", "_hc.v=\"\\\"2000748c-0f57-47e5-b980-dc70e57ab20d.1472525902\\\"\"; dper=" + user.getDper() + "; ua=" + user.getUa() + "; checkInCloseState=ignored; likeTips=ignored; __utma=1.1676118817.1472525940.1476200547.1476338775.12; __utmc=1; __utmz=1.1476200547.11.2.utmcsr=dianping.com|utmccn=(referral)|utmcmd=referral|utmcct=/beijing; ll=7fd06e815b796be3df069dec7836c3df; PHOENIX_ID=0a0102f6-157bca62826-e8532; isChecked=checked; JSESSIONID=2BE2C723CFE01082C220EE2A22D06E62; aburl=1; cy=2; cye=beijing");
			connection.connect();
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}

		return result;
	}


	public static String setXiaobawangRequest(Map<String, String> paramMap, DianPingUser user) {
		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		String result = "";
		BufferedReader in = null;
		try {

			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");
				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}
			String url = "https://act.dianping.com/customized/citic/lottery?" + paramUrl;
			URL realUrl = new URL(url);
			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Host","act.dianping.com");
			connection.setRequestProperty("Accept","*/*");
			connection.setRequestProperty("Connection","keep-alive");
			connection.setRequestProperty("Cookie", "ctu=" + user.getCtu() + "; dper=" + user.getDper() + "; ll=7fd06e815b796be3df069dec7836c3df; ua=" + user.getUa() + "; PHOENIX_ID=0a030e6b-15ada20d047-405de2b; m_flash2=1; pvhistory=\\\"\"6L+U5ZuePjo8L2dldGxvY2FsY2l0eWlkP2xhdD0zOS45MzAwMjAwMjE3NzQyMSZsbmc9MTE2LjQ1MDQ2MDE1OTE0NjkmY2FsbGJhY2s9V2hlcmVBbUkxMTQ4OTcxODI2NzI5OT46PDE0ODk3MTgyNjc5NzhdX1s=\\\"\"; geoType=wgs84; locallat=39.93002002177421; locallng=116.4504601591469; _hc.v=75c75ba9-9c80-653c-e865-e26473d60ff8.1489718266");
			connection.setRequestProperty("User-Agent","Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Mobile/14D27 DKKJ/4.0.3");
			connection.setRequestProperty("Referer","https://evt.dianping.com/midas/1activities/a7037Ie879zZAlYYQ/index.html");
			connection.setRequestProperty("Accept-Encoding","gzip, deflate");
			connection.setRequestProperty("Content-Type","application/javascript; charset=utf-8");


//			connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
//			connection.setRequestProperty("Content-Length","251");
//			connection.setRequestProperty("Origin","http://s.dianping.com");
//			connection.setRequestProperty("X-Request","JSON");
//			connection.setRequestProperty("X-Requested-With","XMLHttpRequest");
			connection.connect();
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}

		return result;
	}

	public static String setPaiPaiRequest(Map<String, String> paramMap) {
		URL realUrl = null;
		try {
			String url = "https://api.m.jd.com/api?";
			realUrl = new URL(url);
			if("https".equalsIgnoreCase(realUrl.getProtocol())){
				SslUtils.ignoreSsl();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		String paramUrl = "";
		StringBuffer strbuffer = new StringBuffer();
		String result = "";
		BufferedReader in = null;
		try {

			if ((paramMap != null) && (paramMap.size() > 0)) {
				for (Map.Entry entry : paramMap.entrySet()) {
					String key = String.valueOf(entry.getKey());
					String value = String.valueOf(entry.getValue());
					strbuffer.append(key);
					strbuffer.append("=");
					strbuffer.append(value);
					strbuffer.append("&");
				}
				paramUrl = strbuffer.toString();
				paramUrl = paramUrl.substring(0, paramUrl.length() - 1);
			}
			String url = realUrl.toString() + paramUrl;
			realUrl = new URL(url);
			URLConnection connection = realUrl.openConnection();
			connection.setRequestProperty("Accept","*/*");
			connection.setRequestProperty("Connection","keep-alive");
//			connection.setRequestProperty("Cookie", "ctu=" + user.getCtu() + "; dper=" + user.getDper() + "; ll=7fd06e815b796be3df069dec7836c3df; ua=" + user.getUa() + "; PHOENIX_ID=0a030e6b-15ada20d047-405de2b; m_flash2=1; pvhistory=\\\"\"6L+U5ZuePjo8L2dldGxvY2FsY2l0eWlkP2xhdD0zOS45MzAwMjAwMjE3NzQyMSZsbmc9MTE2LjQ1MDQ2MDE1OTE0NjkmY2FsbGJhY2s9V2hlcmVBbUkxMTQ4OTcxODI2NzI5OT46PDE0ODk3MTgyNjc5NzhdX1s=\\\"\"; geoType=wgs84; locallat=39.93002002177421; locallng=116.4504601591469; _hc.v=75c75ba9-9c80-653c-e865-e26473d60ff8.1489718266");
			connection.setRequestProperty("User-Agent","ppapp;jdlog;android;3.8.1;12;620fc15cbab3d9f6;Mozilla/5.0 (Linux; Android 12; 22041211AC Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/046011 Mobile Safari/537.36;JDAPPERSHOU_ANDROID");
			connection.setRequestProperty("Referer","https://paipai.m.jd.com/");
			connection.setRequestProperty("Content-Type","application/javascript; charset=utf-8");


//			connection.setRequestProperty("Accept-Language","zh-CN,zh;q=0.8");
//			connection.setRequestProperty("Content-Length","251");
//			connection.setRequestProperty("Origin","http://s.dianping.com");
//			connection.setRequestProperty("X-Request","JSON");
//			connection.setRequestProperty("X-Requested-With","XMLHttpRequest");
			connection.connect();
			in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
			String line;
			while ((line = in.readLine()) != null) {
				result = result + line;
			}
		} catch (Exception e) {
			e.printStackTrace();
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}

		return result;
	}
}
